package com.jfreer.blog.utils;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * User: landy
 * Date: 15/4/19
 * Time: 下午10:07
 */
public class DateTools {
    public static Date toDate(String str) throws ParseException {
        Date result = null;
        try {
            result = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(str);
        } catch (ParseException e) {
            result = new SimpleDateFormat("yyyy-MM-dd").parse(str);
        }
        return result;

    }
}
